import event.*
import heap.THeap
import java.io.File

data class Options(val logAddress: String, val outAddress: String, val resultAddress: String, val capacity: Long, val newRatio: Int = 2, val survivorRatio: Int = 8)

class Analyzer(val options: Options) {
    private val logList = File(options.logAddress).readLines(Charsets.UTF_8)
    private val outList = File(options.outAddress).readLines(Charsets.UTF_8)
    val heap by lazy { THeap(options.capacity, options.newRatio, options.survivorRatio) }
    val eventList by lazy { EventFactory.createEvents(logList, outList) }

    fun analyse() {
        eventList.forEach{ it.notifyTHeap(heap) }
    }
}

fun main(args: Array<String>) {
    val analyzer = Analyzer(Options(
            "Tracker_log.txt",
            "Tracker_out.txt",
            "Analyzer_out.txt",
            4096 * 1024
    ))
    analyzer.analyse()
}